package com.swpu.project.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.swpu.project.common.BaseResponse;
import com.swpu.project.mapper.HeavyMetalMapper;
import com.swpu.project.model.entity.HeavyMetal;
import com.swpu.project.service.IHeavyMetalService;
import org.springframework.stereotype.Service;

import java.util.List;

import static com.swpu.project.util.AuthorityUtil.checkAuthority;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author swpuyanxiegroup1
 * @since 2024-07-29
 */
@Service
public class HeavyMetalServiceImpl extends ServiceImpl<HeavyMetalMapper, HeavyMetal> implements IHeavyMetalService {

    @Override
    public BaseResponse queryData(String belongId) {
        List<HeavyMetal> list = lambdaQuery().eq(HeavyMetal::getBelong, belongId).
                select(HeavyMetal::getDataId,HeavyMetal::getData,HeavyMetal::getName).
                list();


        return BaseResponse.ok(list);
    }

    @Override
    public BaseResponse updateHeavyMetal(List<HeavyMetal> heavyMetals, String blockNum) {


        if(!checkAuthority(blockNum))
            return BaseResponse.fail("您无权进行该操作或数据填写有误");




        return BaseResponse.iFSuccess(saveOrUpdateBatch(heavyMetals));
    }




}
